/*
 *  Copyright (C) void Team 2010 Pedro Batista
 * 
 *  http://code.google.com/p/capacitec
 * 
 *  This file is part of capacitec.
 * 
 *  capacitec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  capacitec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with capacitec.  If not, see <http://www.gnu.org/licenses/>.
 */

package entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author pedro
 */
@Entity
@Table(name = "administrador")
@NamedQueries({
	@NamedQuery(name = "Administrador.findAll", query = "SELECT a FROM Administrador a"),
	@NamedQuery(name = "Administrador.findByPessoaId", query = "SELECT a FROM Administrador a WHERE a.pessoaId = :pessoaId"),
	@NamedQuery(name = "Administrador.findByDataCadastro", query = "SELECT a FROM Administrador a WHERE a.dataCadastro = :dataCadastro")})
public class Administrador implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
        @Basic(optional = false)
        @Column(name = "pessoa_id", nullable = false)
	private Integer pessoaId;
	@Basic(optional = false)
        @Column(name = "dataCadastro", nullable = false)
        @Temporal(TemporalType.DATE)
	private Date dataCadastro;
	@JoinColumn(name = "pessoa_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
        @OneToOne(optional = false)
	private Pessoa pessoa;

	public Administrador() {
	}

	public Administrador(Integer pessoaId) {
		this.pessoaId = pessoaId;
	}

	public Administrador(Integer pessoaId, Date dataCadastro) {
		this.pessoaId = pessoaId;
		this.dataCadastro = dataCadastro;
	}

	public Integer getPessoaId() {
		return pessoaId;
	}

	public void setPessoaId(Integer pessoaId) {
		this.pessoaId = pessoaId;
	}

	public Date getDataCadastro() {
		return dataCadastro;
	}

	public void setDataCadastro(Date dataCadastro) {
		this.dataCadastro = dataCadastro;
	}

	public Pessoa getPessoa() {
		return pessoa;
	}

	public void setPessoa(Pessoa pessoa) {
		this.pessoa = pessoa;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (pessoaId != null ? pessoaId.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Administrador)) {
			return false;
		}
		Administrador other = (Administrador) object;
		if ((this.pessoaId == null && other.pessoaId != null) || (this.pessoaId != null && !this.pessoaId.equals(other.pessoaId))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidades.Administrador[pessoaId=" + pessoaId + "]";
	}

}
